package com.ly.lypopupwindowdemo.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.view.ViewGroup;

import java.util.List;

/**
 * Created by liying on 2017/7/19.
 */

public class MyFragmentPageAdapter extends FragmentPagerAdapter {

    private List<Fragment> fragments; //Fragment集合

    public MyFragmentPageAdapter(FragmentManager fm) {
        super(fm);
    }

    public MyFragmentPageAdapter(FragmentManager fm, List<Fragment> fragments) {
        super(fm);
        this.fragments = fragments;
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        Fragment fm = new Fragment();

        return super.instantiateItem(container, position);
    }

    //当前显示的是第几个
    @Override
    public Fragment getItem(int pos) {
        return fragments.get(pos);
    }
    //计算需要几个item
    @Override
    public int getCount() {
        return fragments.size();
    }

}
